﻿using Com.JunCaiSoft.AutoMapper;
using Com.JunCaiSoft.Hr.Entity;
using Com.JunCaiSoft.Hr.Model;
using Microsoft.AspNetCore.Builder;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Com.JunCaiSoft.Hr
{
    public class HrAutoMapperConfigure
    {
        public static void CreateHrMapper(IApplicationBuilder app)
        {
            var creator = app.UseAutoMapper();

            #region 公司管理映射
            creator.CreateMap<CompanyView, Company>();
            creator.CreateMap<Company, CompanyView>();
            creator.CreateMap<Company, CompanyItem>()
                .ForMember(dest => dest.RegistTime, opt => opt.MapFrom(src => src.RegistTime.ToString("yyyy-MM-dd")))
                .ForMember(dest => dest.EstablishTime, opt => opt.MapFrom(src => src.EstablishTime.ToString("yyyy-MM-dd")))
                .ForMember(dest => dest.AllowBeginTime, opt => opt.MapFrom(src => src.AllowBeginTime.ToString("yyyy-MM-dd")))
                .ForMember(dest => dest.AllowEndTime, opt => opt.MapFrom(src => src.AllowEndTime.ToString("yyyy-MM-dd")))
                .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(src => src.CreateTime.ToString("yyyy-MM-dd")));
            #endregion

            #region 部门管理映射
            creator.CreateMap<Partment, PartmentItem>();
            creator.CreateMap<PartmentItem, Partment>();
            creator.CreateMap<PartmentView, Partment>();
            creator.CreateMap<Partment, PartmentView>();
            #endregion
        }
    }
}
